{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "URL: http://bokeh.pydata.org/en/latest/docs/gallery/legend.html\n",
    "\n",
    "Most examples work across multiple plotting backends, this example is also available for:\n",
    "\n",
    "* [Bokeh - legend_example](../bokeh/legend_example.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "hv.extension('matplotlib')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Defining data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.linspace(0, 4*np.pi, 100)\n",
    "y = np.sin(x)\n",
    "\n",
    "scatter1 = hv.Scatter((x, y), label='sin(x)')\n",
    "scatter2 = hv.Scatter((x, y*2), label='2*sin(x)')\n",
    "scatter3 = hv.Scatter((x, y*3), label='3*sin(x)')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "example1 = scatter1 * scatter2.opts(style=dict(color='orange')) * scatter3.opts(style=dict(color='green'))\n",
    "example2 = (\n",
    "    scatter1 * hv.Curve(scatter1) *\n",
    "    hv.Curve(scatter2).opts(style=dict(linestyle='--', color='orange')) *\n",
    "    scatter3.opts(style=dict(color='green', marker='s')) * hv.Curve(scatter3)\n",
    ")\n",
    "\n",
    "example1.relabel(\"Legend Example\") + example2.relabel(\"Another Legend Example\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
